
<script type="text/javascript" language="javascript">
    function resetText()
    {
        $('#name_cat').val("");
    }
</script>
<?php $baseURL = Zend_Controller_Front::getInstance()->getBaseUrl(); ?>
<div class="border">
    <div class="content">
        <h4 class="header" id="name_action">
            <?php
                if($this->work=="addnew" || $this->work=="delete")
                        echo "Thêm danh mục sách";
                else if($this->work=="edit")
                        echo "Sửa danh mục sách";
            ?>
        </h4>
        <div>
            <form method="post" action="<?php echo $baseURL . '/admin/bookcategory/index'?>">
                <table>
                    <tr>
                        <td>Tên danh mục:</td>
                        <td>
                            <input id="name_cat" name="name_cat" type="text"
                                   value=
                                  "<?php
                                        if($this->work=="addnew" || $this->work=="delete")
                                                echo "";
                                        else if($this->work=="edit")
                                                echo $this->catName;
                                    ?>"/>
                        </td>
                        <td>
                            <input id="submit" name="submit" type="submit"
                                   value=
                                   "<?php  if($this->work=="addnew" || $this->work=="delete")
                                                echo "Thêm mới";
                                        else if($this->work=="edit")
                                                echo "Sửa"; ?>"
                                   />
                        </td>
                    </tr>
                </table>
                <input type="hidden" id="_action" name="_action" value="<?php echo $this->work; ?>"/>
                <input type="hidden" id="id_cat" name="id_cat" value="<?php echo $this->idCat; ?>"/>
            </form>
        </div>
        <div class="clear"></div>
        <h4 class="header">Danh sách danh mục sách</h4>
        <div>
            <table width="98%" cellpadding="0" cellspacing="0" class="data">
                <thead>
                    <tr>
                        <td>Tên danh mục</td>
                        <td>Chức năng</td>
                    </tr>
                </thead>
                <tbody>
                <?php
                    foreach($this->cats as $cat)
                    {
                       echo '<tr>
                                <td class="listname">'.$cat["name"]."</td>
                                <td><a target='main' href='". $baseURL.'/admin/bookcategory/index/work/edit?idCat='. $cat["_id"]  ."'>Sửa</a>|
                                    <a onclick='".'return confirm("Bạn có chắc chắn muốn xóa bản ghi này?");'."' target='main' href='". $baseURL.'/admin/bookcategory/index/work/delete?idCat='. $cat["_id"] ."'>Xóa</a>|
                                    <a onclick='return resetText();' target='main' href='". $baseURL.'/admin/bookcategory/index'."'>Thêm mới</a>
                                    </td>
                           </tr>" ;
                    }
                ?>
               </tbody>
            </table>
        </div>
    </div>
</div>